<a href="javascript:dr_order_{dirname}_select_cart('{$t.id}');">加入购物车</a>



<script type="text/javascript">
    function dr_order_{dirname}_select_cart(id) {
        $.get("/index.php?is_ajax=1&s=order&c=cart&m=select&id="+id+'&mid={dirname}', function(data){
            if (data.code == 1) {
                $('#dr_order_{dirname}_cart_nums').html(data.data);
            } else if (data.code == 2) {
                var url = data.data;
                layer.open({
                    type: 1,
                    title: '商品规格',
                    fix:true,
                    scrollbar: false,
                    shadeClose: true,
                    shade: 0,
                    area: ['600px', '350px'],
                    btn: ['加入购物车', '取消'],
                    yes: function(index, layero){
                        var sku = $('#dr_sku_value').val();
                        var num = $('#dr_buy_num').val();
                        if (!sku) {
                            dr_cmf_tips(0, '商品规格未选择');
                            return;
                        }
                        // 延迟加载
                        var loading = layer.load(2, {
                            shade: [0.3,'#fff'], //0.1透明度的白色背景
                            time: 5000
                        });
                        $.ajax({type: "GET",dataType:"json", url: url+'&sku='+sku+'&num='+num,
                            success: function(json) {
                                layer.close(loading);
                                dr_cmf_tips(json.code, json.msg);
                                $('#dr_order_{dirname}_cart_nums').html(json.data);
                                return false;
                            },
                            error: function(HttpRequest, ajaxOptions, thrownError) {
                                layer.closeAll('loading');
                                alert(HttpRequest.responseText);
                            }
                        });
                        return false;
                    },
                    content: data.msg
                });
                return;
            }
            dr_cmf_tips(data.code, data.msg);
        }, 'json');
    }
</script>